clear all; 

pass_counter = 0; %count the times when pass win
donotpass_counter = 0;%count the times when donotpass win
n=100;
%n = 1000;
%n = 5000;
%n = 10000;
%n=100000;
%n=1000000;

for i=1:1:n
    roll_1 = randi(6) + randi(6);

    if roll_1==12;       
    elseif (roll_1==7||roll_1==11)
        pass_counter = pass_counter + 1;                 
    elseif (roll_1==2||roll_1==3)
        donotpass_counter = donotpass_counter + 1;
    else       
     %%if roll_1=4, 5, 6, 8, 9, 10,  we need to roll until 7 or roll_1       
        roll_2 = randi(6) + randi(6);   
                while (roll_2~=7 && roll_2~=roll_1)
                    roll_2 = randi(6) + randi(6);
                end
                if roll_2==roll_1
                    pass_counter = pass_counter + 1;
                else
                    donotpass_counter = donotpass_counter + 1;
                end      
    end
end
prob_pass = pass_counter/n;
prob_donotpass = donotpass_counter/n;
